import 'package:example/widget_demo/page_title_demo.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dk_form/flutter_dk_form.dart';

class ChooseDemoPage extends StatelessWidget {
  static const String routeName = '/page/choose_demo';
  static const String name = "ChooseDemoPage";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ChooseDemoPage"),
      ),
      body: SingleChildScrollView(
          child: Container(
        color: Color(0xFFFF7F7F7),
        child: Column(
          children: <Widget>[
            Text("选择标签 单选"),
            ChooseLabelWidget(
              title: '主合同审核状态',
              data: getList(),
              hasLine: true,
              isRadio: true,
              onChanged: onSelected,
            ),
            Text("选择标签 多选"),
            ChooseLabelWidget(
              title: '主合同审核状态',
              data: getList1(),
              hasLine: true,
              onChanged: onSelected,
            ),
            Text("单选框"),
            Container(
              color: Colors.white,
              child: Column(
                children: <Widget>[
                  Container(
                    padding: EdgeInsets.only(
                      left: 16,
                    ),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Text('电梯',
                            style: TextStyle(
                                color: Color(0xFF666666), fontSize: 14)),
                        CustomRadioButtonWidget(
                          checkListener: customRadioButtonCheckListener,
                        )
                      ],
                    ),
                  ),
                  Divider(height: 0.5, indent: 16, color: Color(0xFFEBEBEB)),
                ],
              ),
            ),
            Text("幽灵导航"),
            HorizontalListWidget(getList()),
            Text("展示标签"),
            ShowLabelWidget(data: getList()),
            Text("展示标签（可点击跳转）"),
            ShowLabelWidget(
              data: getList2(),
              onClick: (item) {
                Navigator.pushNamed(context, item.urlScheme);
              },
            ),
          ],
        ),
      )),
    );
  }

  onSelected(List data) {
    if (data != null) {
      data.forEach((item) {
        print(item.toString());
      });
    }
  }

  customRadioButtonCheckListener(
      RadioButtonSelectedState radioButtonSelectedState) {
    print(radioButtonSelectedState);
  }

  List<ChooseLabelBean> getList() {
    List<ChooseLabelBean> list = List();
    list.add(ChooseLabelBean(key: 0.toString(), content: "未提交审核"));
    list.add(ChooseLabelBean(key: 1.toString(), content: "待审批"));
    list.add(ChooseLabelBean(key: 2.toString(), content: "合格"));
    list.add(ChooseLabelBean(key: 3.toString(), content: "不合格"));
    list.add(ChooseLabelBean(key: 4.toString(), content: "作废"));
    list.add(ChooseLabelBean(key: 5.toString(), content: "暂未提交审核"));
    return list;
  }

  List<ChooseLabelBean> getList2() {
    List<ChooseLabelBean> list = List();
    list.add(ChooseLabelBean(
        key: 0.toString(),
        content: "未提交审核",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    list.add(ChooseLabelBean(
        key: 1.toString(),
        content: "待审批",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    list.add(ChooseLabelBean(
        key: 2.toString(),
        content: "合格",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    list.add(ChooseLabelBean(
        key: 3.toString(),
        content: "不合格",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    list.add(ChooseLabelBean(
        key: 4.toString(),
        content: "作废",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    list.add(ChooseLabelBean(
        key: 5.toString(),
        content: "暂未提交审核",
        selected: true,
        urlScheme: TitleDemoPage.routeName));
    return list;
  }

  List<ChooseLabelBean> getList1() {
    List<ChooseLabelBean> list = List();
    list.add(ChooseLabelBean(key: 0.toString(), content: "未提交审核"));
    list.add(ChooseLabelBean(key: 1.toString(), content: "待审批"));
    list.add(ChooseLabelBean(key: 2.toString(), content: "合格"));
    list.add(ChooseLabelBean(key: 3.toString(), content: "不合格"));
    list.add(ChooseLabelBean(key: 4.toString(), content: "作废"));
    list.add(ChooseLabelBean(key: 5.toString(), content: "暂未提交审核"));
    return list;
  }
}
